package cn.exrick.xboot.modules.content.serviceimpl;

import cn.exrick.xboot.common.vo.SearchVo;
import cn.exrick.xboot.modules.base.dao.DepartmentHeaderDao;
import cn.exrick.xboot.modules.base.entity.DepartmentHeader;
import cn.exrick.xboot.modules.content.dao.HontDepartmentHeaderDao;
import cn.exrick.xboot.modules.content.entity.HontDepartmentHeader;
import cn.exrick.xboot.modules.content.service.HontDepartmentHeaderService;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 部门负责人接口实现
 * @author Exrick
 */
@Slf4j
@Service
@Transactional
public class HontDepartmentHeaderServiceImpl implements HontDepartmentHeaderService {

    @Autowired
    private HontDepartmentHeaderDao departmentHeaderDao;

    @Override
    public HontDepartmentHeaderDao getRepository() {
        return departmentHeaderDao;
    }


    @Override
    public List<String> findHeaderByHontDepartmentId(String departmentId, Integer type) {

        List<String> list = new ArrayList<>();
        List<HontDepartmentHeader> headers = departmentHeaderDao.findByHontDepartmentIdAndType(departmentId, type);
        headers.forEach(e->{
            list.add(e.getHontUserId());
        });
        return list;
    }

    @Override
    public void deleteByHontDepartmentId(String departmentId) {

        departmentHeaderDao.deleteByHontDepartmentId(departmentId);
    }

    @Override
    public void deleteByHontUserId(String userId) {

        departmentHeaderDao.deleteByHontUserId(userId);
    }

    @Override
    public List<HontDepartmentHeader> findByHontUserId(String userId) {
        return departmentHeaderDao.findByHontUserId(userId);
    }
}